<template>
	<view>
		<view>
			<u-avatar></u-avatar>
			<u-button text="重新保存" @click="download"></u-button>
		</view>
	</view>
</template>

<script>
	import Config from "@/common/config.js"
	export default{
		name:"downaload",
		data(){
			return {
				
			}
		},
		methods:{
			download(mediaId,type){
				uni.showLoading({
					title:"正在保存"
				})
				let ctx = type == 'video' ? '.mp4' : '.jpg'
				uni.downloadFile({
					url: Config.base_Url + "ins_img/" + mediaId + ctx,
					success:(res)=>{
						console.log(res)
						uni.saveImageToPhotosAlbum({
							filePath:res.tempFilePath,
							success:(res)=>{
								uni.hideLoading()
								uni.showToast({
									title:"保存成功",
									icon:"success",
									duration:1000
								})
							},
							fail:(err)=>{
								console.log(err)
								uni.hideLoading()
								uni.showToast({
									title:"保存失败",
									icon:"error",
									duration:1000
								})
							}
						})
					}
				})
			}
		},
		onLoad(){
			
		}
	}
</script>

<style>
</style>